//
//  NewsViewController.m
//  网易
//
//  Created by dllo on 15/11/10.
//  Copyright © 2015年 HuangLiJing. All rights reserved.
//

#import "NewsViewController.h"
#import "NewsTableViewCell.h"
@interface NewsViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic, retain)UIPageControl *pageC;
@property(nonatomic, retain)UIScrollView *myScrollview;

@property(nonatomic, retain)UIScrollView *scrollView1;
@end

@implementation NewsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    self.navigationItem.title = @"Bottle";
    
    self.myScrollview = [[UIScrollView alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
    self.myScrollview.backgroundColor = [UIColor blackColor];
    [self.view addSubview:self.myScrollview];
    [self.myScrollview release];

     self.myScrollview.contentSize = CGSizeMake(375, 667 * 2 );
    self.myScrollview.backgroundColor = [UIColor whiteColor];
    
    self.scrollView1 = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 375, 140)];
    [self.myScrollview addSubview:self.scrollView1];
    self.scrollView1.contentSize = CGSizeMake(375 * 3, 120);
    self.scrollView1.backgroundColor = [UIColor darkGrayColor];
    
    self.scrollView1.pagingEnabled = YES;
    //取消边界反弹效果
    self.scrollView1.bounces = NO;
    
    
    
    
    self.myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 140, 375, 667 * 2 - 140) style:UITableViewStylePlain];
    self.myTableView.delegate = self;
    self.myTableView.dataSource = self;
    [self.view addSubview:self.myTableView];
    [_myTableView release];
    
     [self.myTableView registerClass:[NewsTableViewCell class] forCellReuseIdentifier:@"cell"];
    
    
    
    
    self.pageC = [[UIPageControl alloc]initWithFrame:CGRectMake( 130 ,100 , 100, 60)];
    
    self.pageC.backgroundColor = [UIColor clearColor];
    [self.view addSubview:self.pageC];
    [self.pageC release];
    
    //设置页码个数
    self.pageC.numberOfPages = 3;
    
    //设置当前页码颜色
    self.pageC.currentPageIndicatorTintColor = [UIColor lightGrayColor];
    
    //设置普通页码颜色
    self.pageC.pageIndicatorTintColor = [UIColor blackColor];
    
    //设置当前选中页码
    self.pageC.currentPage = 0;
    
    
    //核心方法
    
    [self.pageC addTarget:self action:@selector(pageAction:) forControlEvents: UIControlEventValueChanged ];
    
    
    
    
    
    
    
    
    
    
}


- (void)pageAction:(UIPageControl *)pageC{
    
    //打印当前页码下标
    NSLog(@" currentPage = %ld", pageC.currentPage);
    
    
    [self.scrollView1 setContentOffset:CGPointMake(pageC.currentPage, 0) animated:YES];
    
    
}

    


    
    
    
    



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    
    return 100;
    
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *cellIdentifier = @"cell";
    NewsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    
    
  // cell.textLabel.text = @"哈哈";
    return cell;
    
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 100;
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
